package pe.gob.pj.sri.web.action.analidesa;

import java.util.ArrayList;
import java.util.List;

import javax.faces.context.ExternalContext;
import javax.faces.context.FacesContext;
import javax.servlet.http.HttpSession;

import org.apache.log4j.Logger;
import org.richfaces.component.html.HtmlDataTable;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

import pe.gob.pj.sri.bean.Ticket;
import pe.gob.pj.sri.bean.Usuario;
import pe.gob.pj.sri.servicio.TicketService;
import pe.gob.pj.sri.servicio.UsuarioService;
import pe.gob.pj.sri.web.action.coordesa.AsignacionTicketAction;

@Scope("session")
@Controller("atenderTicketAction")
public class AtenderTicketAction {
	@Autowired
    private static final Logger LOGGER = Logger.getLogger(AsignacionTicketAction.class);
	@Autowired
	private Ticket ticket;
	@Autowired
	private Usuario analista;
	
	@Autowired
	private TicketService ticket_service;
//	@Autowired
//	private UsuarioService usuario_service;
//	
	private List<Ticket> lista_tickets_no_atendidos;
	private HtmlDataTable radioDataTableTicketNA;
	
	private List<Ticket> lista_tickets_en_atencion;
	private HtmlDataTable radioDataTableTicketEA;
	
	
	public AtenderTicketAction() {
		this.lista_tickets_no_atendidos = new ArrayList<Ticket>();
		this.lista_tickets_en_atencion = new ArrayList<Ticket>();;
	}
	
	public String getRecuperar_ticketsEA(){
		System.out.println("RECUPERAR TICKETS EN ATENCION");
		ExternalContext context = FacesContext.getCurrentInstance().getExternalContext();
		HttpSession session = (HttpSession)context.getSession(true);
		analista = (Usuario)session.getAttribute("USUARIO_ACTUAL");
		this.lista_tickets_en_atencion = this.ticket_service.listarTicketsEnAtencion(analista.getIdUsuario());
		//lista_tickets_no_atendidos = this.ticket_service.listarTicket(null); 
		System.out.println("Atender Ticket\nAnalista idUauario: "+analista.getIdUsuario());
		return "";
	}
	
	
	public TicketService getTicket_service() {
		return ticket_service;
	}
	public void setTicket_service(TicketService ticket_service) {
		this.ticket_service = ticket_service;
	}
	public HtmlDataTable getRadioDataTableTicketNA() {
		return radioDataTableTicketNA;
	}
	public void setRadioDataTableTicketNA(HtmlDataTable radioDataTableTicketNA) {
		this.radioDataTableTicketNA = radioDataTableTicketNA;
	}
	public List<Ticket> getLista_tickets_en_atencion() {
		return lista_tickets_en_atencion;
	}
	public void setLista_tickets_en_atencion(List<Ticket> lista_tickets_en_atencion) {
		this.lista_tickets_en_atencion = lista_tickets_en_atencion;
	}
	public HtmlDataTable getRadioDataTableTicketEA() {
		return radioDataTableTicketEA;
	}
	public void setRadioDataTableTicketEA(HtmlDataTable radioDataTableTicketEA) {
		this.radioDataTableTicketEA = radioDataTableTicketEA;
	}

//	public UsuarioService getUsuario_service() {
//		return usuario_service;
//	}
//	public void setUsuario_service(UsuarioService usuario_service) {
//		this.usuario_service = usuario_service;
//	}

	public Ticket getTicket() {
		return ticket;
	}
	public void setTicket(Ticket ticket) {
		this.ticket = ticket;
	}
	public Usuario getAnalista() {
		return analista;
	}
	public void setAnalista(Usuario analista) {
		this.analista = analista;
	}
	public List<Ticket> getLista_tickets_no_atendidos() {
		return lista_tickets_no_atendidos;
	}
	public void setLista_tickets_no_atendidos(
			List<Ticket> lista_tickets_no_asignados) {
		this.lista_tickets_no_atendidos = lista_tickets_no_asignados;
	}
	public static Logger getLogger() {
		return LOGGER;
	}

}
